package com.ruoyi.project.mydo.detail.service.impl;

import java.util.List;

import com.ruoyi.project.mydo.detail.mapper.MydoJobDetailFinishMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.mydo.detail.mapper.MydoJobDetailMapper;
import com.ruoyi.project.mydo.detail.domain.MydoJobDetail;
import com.ruoyi.project.mydo.detail.service.IMydoJobDetailService;
import com.ruoyi.common.core.text.Convert;

/**
 * 作业子表Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-04-10
 */
@Service
public class MydoJobDetailServiceImpl implements IMydoJobDetailService 
{
    @Autowired
    private MydoJobDetailMapper mydoJobDetailMapper;
    @Autowired
    private MydoJobDetailFinishMapper mydoJobDetailFinishMapper;

    /**
     * 查询作业子表
     * 
     * @param jobDetailId 作业子表主键
     * @return 作业子表
     */
    @Override
    public MydoJobDetail selectMydoJobDetailByJobDetailId(String jobDetailId)
    {
        return mydoJobDetailMapper.selectMydoJobDetailByJobDetailId(jobDetailId);
    }

    /**
     * 查询作业子表列表
     * 
     * @param mydoJobDetail 作业子表
     * @return 作业子表
     */
    @Override
    public List<MydoJobDetail> selectMydoJobDetailList(MydoJobDetail mydoJobDetail)
    {
        List<MydoJobDetail>  list = null;
        list = mydoJobDetailMapper.selectMydoJobDetailList(mydoJobDetail);
        if(list.size() ==0){
            list = mydoJobDetailFinishMapper.selectMydoJobDetailFinishList(mydoJobDetail);
        }
            return list;
    }

    /**
     * 新增作业子表
     * 
     * @param mydoJobDetail 作业子表
     * @return 结果
     */
    @Override
    public int insertMydoJobDetail(MydoJobDetail mydoJobDetail)
    {
        return mydoJobDetailMapper.insertMydoJobDetail(mydoJobDetail);
    }

    /**
     * 修改作业子表
     * 
     * @param mydoJobDetail 作业子表
     * @return 结果
     */
    @Override
    public int updateMydoJobDetail(MydoJobDetail mydoJobDetail)
    {
        return mydoJobDetailMapper.updateMydoJobDetail(mydoJobDetail);
    }

    /**
     * 批量删除作业子表
     * 
     * @param jobDetailIds 需要删除的作业子表主键
     * @return 结果
     */
    @Override
    public int deleteMydoJobDetailByJobDetailIds(String jobDetailIds)
    {
        return mydoJobDetailMapper.deleteMydoJobDetailByJobDetailIds(Convert.toStrArray(jobDetailIds));
    }

    /**
     * 删除作业子表信息
     * 
     * @param jobDetailId 作业子表主键
     * @return 结果
     */
    @Override
    public int deleteMydoJobDetailByJobDetailId(String jobDetailId)
    {
        return mydoJobDetailMapper.deleteMydoJobDetailByJobDetailId(jobDetailId);
    }
}
